<{Tinclude "commom/admin_header"}>
<link href="<?php echo CSS_PATH;?>jquery-ui.css" rel="stylesheet" />
 <script src="<?php echo JS_PATH;?>datepicker-zh-TW.js"></script>
 <section id="container" >
      
      <!--顶部-->
      <{Tinclude"commom/admin_inner_header"}>
      <!--顶部-->
      
       <{Tinclude"commom/admin_left_menu"}>
       
       <section id="main-content">
          <section class="wrapper">
          	<h3><i class="<{if $___menuinfo["iconclass"]}><{$___menuinfo["iconclass"]}><{else}>fa fa-list-ul<{/if}>"></i><{$___menuinfo["base_name"]}></h3>
                <div class="row mt">
                    <div class="col-md-12">
                       <div class="form-panel">
                           
                           <form class="form" role="form" action="<{echo Common::RewriteUrl($jp_arg["c"],$jp_arg["a"]);}>"  method="post">  
                       <input type="hidden" name="id" value="<{$id}>"/>         
                       <input type="hidden" value="<{$data["room_id"]}>" class="form-control" name="submit_room_id">                        
      <div class="form-group input-group col-md-3">
        <div class="input-group">
          
       
          <input type="text" value="<{$data["room_no"]}>" class="form-control" name="submit_room_no" placeholder="输入房间编号">
          <span class="input-group-btn">
              <button class="btn btn-default" data-toggle="modal" data-target="#roomlist" type="button">选择房间</button>
          </span>
        </div>
      </div>
      <div class="form-group input-group col-md-3">
         <span class="input-group-addon">租金</span>
          <input type="text" class="form-control" name="rent" value="<{$data["rent"]}>" placeholder="请输入租金">        
          <span class="input-group-addon">(元/月)</span>
      </div>
                              <div class="form-group input-group col-md-3">
         <span class="input-group-addon">押金</span>
          <input type="text" class="form-control" name="deposit" value="<{$data["deposit"]}>" placeholder="请输入押金">        
          <span class="input-group-addon">(元)</span>
      </div>
                               
                               
         <input type="hidden" class="form-control" value="<{$data["user_id"]}>" name="submit_user_id">                       
       <div class="form-group input-group col-md-4">
      
             
         
          <input type="text" class="form-control" value="<{$data["user_name"]}>" name="submit_user_name" placeholder="输入租户姓名">
          <span class="input-group-btn">
              <button class="btn btn-default" data-toggle="modal" data-target="#userlist" type="button">选择用户</button>
              <button class="btn btn-default" data-toggle="modal" data-target="#useradd" type="button">创建用户</button>
          </span>
          

      </div>
         <h4 class="mb"><i class="fa fa-angle-right"></i>选件房间配备</h4>
         <{foreach $peijian as $v}>
         <div class="form-group col-md-3 col-xs-12">
        <label>
            <input type="checkbox" class="peijian" name="peijian_id[]" value="<{$v["id"]}>" <{if isset($peijianlist[$v["id"]])}>checked<{/if}>>
          <{$v["base_name"]}>
           
        </label>
             <input type="hidden" class="form-control" name="peijian_base_name[<{$v["id"]}>]" value="<{$v["base_name"]}>" />
             <input type="text" class="form-control jphidden" name="price[<{$v["id"]}>]" <{if isset($peijianlist[$v["id"]])}>value="<{echo $peijianlist[$v["id"]]["peijian_price"]}>"<{else}>value="<{$v["price"]}>"<{/if}> placeholder="请配件价格">      
         </div>
      <{/foreach}>
      <div class="clearfix"></div>
      <div class="form-group input-group col-md-3">
          <span class="input-group-addon">租房日期<span class="fa fa-calendar"></span></span>
          <input type="text" class="form-control" id="create_time" name="create_time" placeholder="输入租房日期">
      </div>         
                        
  <input class="btn btn-primary btn-block" type="submit" name="submit" value="提交">
                   
                               
                           </form>
                           
                           
                           
                       </div>
                    </div>
                        
                </div>
          </section>
       </section>
 </section>



<!--房间列表-->
<div class="modal fade" id="roomlist" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel">房间列表</h4>
      </div>
      <div class="modal-body">
        <form>
 <div class="dropdown" >
  <button class="btn btn-default dropdown-toggle pull-left" type="button"   data-toggle="dropdown" aria-expanded="true">
      <span id="droplistval">选择房子</span>
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" id="chosebuild">
     <{foreach $loulist as $v}>
     <li role="presentation" data-id="<{$v["id"]}>" data-name="<{$v["base_name"]}>"><a role="menuitem" tabindex="<{$v["id"]}>" href="javascript:void(0);"><{$v["base_name"]}></a></li>
    <{/foreach}>
  </ul>
     
     
     <div class="col-md-4 col-xs-5 pull-left" style="margin-left: 10px;">
   
            
                <input type="text" name="room_no" id="roomno" class="form-control" placeholder="请输入房间编号" aria-describedby="basic-addon1">

           </div>
     <div class="clearfix"></div>
     
     
</div>
         
            <div id="unseen" class="margin_top20">
                
                
            </div>        
            
            
            
            
            
            
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<!--end房间列表-->



<!--用户列表-->


<div class="modal fade" id="userlist" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel">租客列表</h4>
      </div>
      <div class="modal-body">
        <form>
 
     
     

<input type="text" name="user_name" id="user_name" class="form-control" placeholder="请输入姓名" aria-describedby="basic-addon1">


         
            <div id="unseenuser" class="margin_top20">
                
                
            </div>        
            
            
            
            
            
            
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<!--end用户列表-->


<!--创建用户-->
<div class="modal fade" id="useradd" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel">添加租客</h4>
      </div>
      <div class="modal-body">
        
          <iframe id="myiframe" class="myiframe" src="<{echo Common::RewriteUrl("Tenant","public_ajax_tenantadd");}>">
          </iframe>
          
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-success" id="btnuseradd">提交</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>

<!--end创建用户-->


<script>
$("#chosebuild li").click(function(){
    var id=$(this).data("id");
    var name=$(this).data("name");
   $("#droplistval").html(name);
   $("#droplistval").data("id",id);
    search();
   
});
$('#roomlist').on('shown.bs.modal', function () {
  search();
});

$('#userlist').on('shown.bs.modal', function () {
  searchuser();
});
$("#roomno").keyup(function(){
    search();
});


$("#user_name").keyup(function(){
    searchuser();
});
function search(){
    var buildid= $("#droplistval").data("id");
    var roomno= $("#roomno").val();
    $.post("<{echo Common::RewriteUrl("Rental","public_ajax_roomlist");}>",{"build_id":buildid,"room_no":roomno},function(data){
        $("#unseen").html(data);
    });
}
function useraddhide(){
    $("#useradd").modal('hide');
}

function searchuser(){
    var user_name= $("#user_name").val();
    $.post("<{echo Common::RewriteUrl("Rental","public_ajax_userlist");}>",{"user_name":user_name},function(data){
        $("#unseenuser").html(data);
    });
}

function pageclick(evt){
            var obj=$(evt);
            var page=obj.data("pageinfo");
            var buildid= $("#droplistval").data("id");
            var roomno= $("#roomno").val();
            $.post("<{echo Common::RewriteUrl("Rental","public_ajax_roomlist");}>",{"build_id":buildid,"room_no":roomno,"page":page},function(data){
                 $("#unseen").html(data);
            });
        }
function userpageclick(evt){
            var obj=$(evt);
            var page=obj.data("pageinfo");
            var user_name= $("#user_name").val();
            $.post("<{echo Common::RewriteUrl("Rental","public_ajax_userlist");}>",{"user_name":user_name,"page":page},function(data){
                 $("#unseenuser").html(data);
            });
        }
        $("#btnuseradd").click(function(){
            var ifr=document.getElementById('myiframe');
            var iframe=$(ifr);
            iframe.contents().find("#myform").submit();
        });
        $(".peijian").click(function(){
            var ck=$(this).get(0).checked;
            if(ck){
                $(this).parent().parent().find(".jphidden").css("display","block");
            }else{
                $(this).parent().parent().find(".jphidden").css("display","none");
            }
        });
        
        	$(function() {
            
                $( "#create_time" ).datepicker();
                $( "#create_time" ).datepicker('setDate',new Date("<{echo date("Y-m-d",$data["create_time"])}>"));
		$( "#create_time" ).datepicker("option", "dateFormat","yy-mm-dd");
                $( "#create_time" ).datepicker($.datepicker.regional[ "zh-TW"] );
	});
        
        
    $(document).ready(function(){
        $(".peijian").each(function(){
            if($(this).get(0).checked){
                $(this).parent().parent().find(".jphidden").css("display","block");
            }else{
               $(this).parent().parent().find(".jphidden").css("display","none"); 
            }
        });
    });
</script>
<{Tinclude"commom/admin_footer"}>